package com.baseweb.webadmin.core.constants;

import java.util.ArrayList;
import java.util.List;

public enum OrderStatus {
    NEW_ORDER(-1,"待审核"), VERIFY_ORDER(1,"审核通过,待接单"), BIZ_RECEIVE_ORDER(2,"商家接单"),
        CANCEL_NOT_REFUND(3,"订单取消"),CANCEL_REFUND(4,"订单取消已退款"),BIZ_FINISH_ORDER(5,"商家完成订单"),CONFIRM_ORDER(6,"用户确认完成订单"),
    CONFIRM_REFUND(7,"同意退款"),REFUSD_REFUND(8,"拒绝退款"),USER_COMMENT(9,"已评论");

    private int code;
    private String name;
    OrderStatus(int code, String name){
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static List<OrderStatus> getAllData(){
        List<OrderStatus> result = new ArrayList<OrderStatus>();
        for (OrderStatus current : OrderStatus.values())
        {
            result.add(current);
        }
        return result;
    }

    public static OrderStatus getNameByCode(int code){
        List<OrderStatus> allData = getAllData();
        for (OrderStatus status : allData){
            if (status.getCode() == code){
                return status;
            }
        }
        return null;
    }

}
